from typing import List

"""
2,3,4,5,6, 7,8,0,1
旋转点在右边
在右边找


2,3,4,5,6, 7,8,0


7,8,1,2,3,4,5,6
旋转点在左边，在左边找
"""


class Solution:
    def findMin(self, nums: List[int]) -> int:
        min_value = nums[0]

        def half(left, right):

            nonlocal min_value
            mid = (left + right) // 2
            min_value = min(min_value, nums[mid])

            if left >= right:
                return
            if right - left == 1:
                min_value = min(min_value, nums[left], nums[right])

            if nums[left] < nums[mid] > nums[right]:
                # 旋转点在右边

                half(mid + 1, right)
            else:
                half(left, mid - 1)

        half(0, len(nums) - 1)
        return min_value
